import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/register/index.vue')
  },
  {
    path: '/main',
    name: 'Main',
    component: () => import('@/views/main/index.vue'),
    meta: { requiresAuth: true } // 添加认证要求
  },
  {
    path: "/search",
    name: "Search",
    component: () => import('@/views/search/index.vue'),
    meta: { requiresAuth: true } // 添加认证要求
  },
  {
    path: "/merchant/:id",
    name: "Merchant",
    component: () => import('@/views/detail/index.vue'),
    meta: { requiresAuth: true } // 添加认证要求
  },
  {
    path: "/edit",
    name: "edit",
    component: () => import('@/components/editUserInfo/index.vue'),
    meta: { requiresAuth: true } // 添加认证要求
  }
  
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router